package com.qing.expert.modules.expert.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qing.expert.modules.expert.entity.ExpertRating;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ExpertRatingMapper extends BaseMapper<ExpertRating> {

    /**
     * 获取达人的平均评分
     */
    @Select("SELECT COALESCE(AVG(rating), 5.0) FROM expert_rating WHERE expert_id = #{expertId}")
    Double getAverageRating(String expertId);
}